home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / telecomm / sticpsrc.lzh / SOURCE.ARC / TNC2.H < prev    next >
C/C++ Source or Header  |  1989-04-15  |  4KB  |  88 lines

  1. /* TNC-2 emulator for use by RLI or MBL bbs */
  2.  
  3. #define TNCPARAMS    79        /* number of TNC parameter bytes */
  4. #define TNCTEXTS    4        /* number of TNC parameter texts */
  5. #define TNCTIMERS    3        /* number of TNC every/after timers */
  6.  
  7. /* input/output fifo */
  8. struct tncfifo {
  9.     char *begin;            /* first byte of buffer */
  10.     char *end;            /* last byte of buffer + 1 */
  11.     char *in;            /* where bytes are added */
  12.     char *out;            /* where bytes are removed */
  13.     int  num;            /* number of bytes in buffer */
  14. };
  15.  
  16. /* controlblock for each BBS TNC supported */
  17. struct tnc {
  18.     /* static info about this TNC */
  19.     struct tnc *next;        /* next in list */
  20.     int dev;            /* TNC I/O device (COM number) */
  21.     struct interface *interface;    /* associated interface */
  22.     struct ax25_call *axcall;    /* associated AX.25 port */
  23.     /* state information, updated by connections and mode changes */
  24.     struct ax25_cb *axp;        /* AX.25 connection, if any */
  25.     int linepos;            /* current line buffer pos */
  26.     int passc;            /* PASS-character flag */
  27.     int mode;            /* operation mode */
  28. #define TM_CMD        0        /* command mode */
  29. #define TM_CONV        1        /* converse mode */
  30. #define TM_TRANS    2        /* transparent mode */
  31. #define TM_KISS        3        /* KISS mode */
  32.     /* parameters of the TNC set by the various customization commands */
  33.     int conmode;            /* connect mode */
  34.     char param[TNCPARAMS];        /* TNC parameter info */
  35.     char *text[TNCTEXTS];        /* TNC parameter texts */
  36.     struct timer timer[TNCTIMERS];    /* TNC timers */
  37.     char every[TNCTIMERS];        /* EVERY/AFTER flag for timers */
  38.     struct ax25 unproto;        /* UI address plus digis */
  39.     /* input/output buffer areas */
  40.     int status;            /* various I/O status flags */
  41. #define TS_TXBUF    0x01        /* transmit buffer enabled */
  42. #define TS_RXOVR    0x02        /* receive overrun */
  43. #define TS_TXOVR    0x04        /* transmit overrun */
  44. #define TS_RXSTOP    0x08        /* receive flow control */
  45. #define TS_TXSTOP    0x10        /* transmit flow control */
  46. #define TS_TXHOLD    0x20        /* transmit hold by "drop RTS" */
  47. #define TS_BREAK    0x40        /* BREAK received */
  48. #define TS_DCD        0x80        /* TNC is CONNECTED (give DCD) */
  49.     struct tncfifo input;        /* input (from client to TNC) FIFO */
  50.     struct tncfifo output;        /* output (from TNC to client) FIFO */
  51.     struct slip slip;        /* SLIP struct for KISS emulation */
  52. #ifdef ATARI_ST
  53.     void (*save_vec[4])();        /* saved I/O vectors */
  54. #endif
  55.     char linebuf[260];        /* input line buffer */
  56. };
  57. #define NULLTNC        ((struct tnc *) 0)
  58.  
  59. extern struct tnc *tnc2s;        /* one for every emulated TNC2 */
  60.  
  61. /* command table entry for the emulated TNC */
  62. struct tnccommand {
  63.     char name[9];            /* command name +\0, max 8 chars */
  64.     char type;            /* selects type of command using: */
  65. #define TC_EXEC        0        /* executed using function spec'd */
  66. #define TC_ON_OFF    1        /* on/off switch */
  67. #define TC_DECVAL    2        /* decimal value */
  68. #define TC_HEXVAL    3        /* hexadecimal value */
  69. #define TC_TEXT        4        /* text value */
  70. #define TC_TIMER    5        /* timer every/after */
  71. #define TC_MISC        6        /* miscellaneous setting */
  72.     int paramnum;            /* parameter number (if any) */
  73.     void (*func)();            /* executing function (if any) */
  74. };
  75.  
  76. /* return values from tnc2_line() */
  77.  
  78. #define TL_INCOMPLETE    0        /* incomplete line, wait for next ch */
  79. #define TL_CANCEL    1        /* line cancelled by CANLINE */
  80. #define TL_COMPLETE    2        /* complete line entered */
  81. #define TL_PACKET    3        /* complete packet entered */
  82. #define TL_COMMAND    4        /* escape to commandmode */
  83.  
  84. /* magic character return values */
  85.  
  86. #define TCH_NOCHAR    -1        /* no character available */
  87. #define TCH_BREAK    256        /* received a BREAK */
  88.